//
//  ALPS_ClassifyRightTableCell.m
//  Alps
//
//  Created by dllo on 16/6/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ALPS_ClassifyRightTableCell.h"

@implementation ALPS_ClassifyRightTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.iconImgView = [[UIImageView alloc] init];
        [self.contentView addSubview:_iconImgView];
        
        self.bigTitleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_bigTitleLabel];
        
        self.smallTitleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_smallTitleLabel];
        
        self.playCountsLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_playCountsLabel];
        
        self.jiCountsLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_jiCountsLabel];
        
    }
    return self;
}

- (void)setModel:(ALPS_RightTableCellModel *)model
{
    [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:model.coverLarge]];
    self.bigTitleLabel.text = model.title;
    self.smallTitleLabel.text = model.trackTitle;
    self.playCountsLabel.text = [NSString stringWithFormat:@"播放%.1f万", model.playsCounts / 10000.0];
    self.jiCountsLabel.text = [NSString stringWithFormat:@"更新至%ld集", model.tracks];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.iconImgView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.top).offset(5);
        make.left.equalTo(self.contentView.left).offset(5);
        make.bottom.equalTo(self.contentView.bottom).offset(-15);
        make.width.equalTo(self.contentView.height).offset(-20);
    }];
    
    [self.bigTitleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImgView);
        make.left.equalTo(self.iconImgView.right).offset(5);
        make.height.equalTo(20);
        make.right.equalTo(self.contentView.right).offset(-5);
    }];
    self.bigTitleLabel.font = [UIFont systemFontOfSize:15];
    
    [self.smallTitleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self.bigTitleLabel);
        make.top.equalTo(self.bigTitleLabel.bottom).offset(0);
        make.bottom.equalTo(self.contentView.bottom).offset(-20);
    }];
    self.smallTitleLabel.font = [UIFont systemFontOfSize:12];
    self.smallTitleLabel.numberOfLines = 0;
    
    [self.playCountsLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImgView.right).offset(5);
        make.bottom.equalTo(self.contentView.bottom);
        make.height.equalTo(20);
        make.width.equalTo(self.bigTitleLabel.width).multipliedBy(0.5);
    }];
    self.playCountsLabel.font = [UIFont systemFontOfSize:11];
    self.playCountsLabel.textColor = [UIColor grayColor];
    
    [self.jiCountsLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.height.and.width.equalTo(self.playCountsLabel);
        make.left.equalTo(self.playCountsLabel.right);
    }];
    self.jiCountsLabel.font = [UIFont systemFontOfSize:11];
    self.jiCountsLabel.textColor = [UIColor grayColor];
    
}

@end
